package com.top.mall.main.access

import androidx.lifecycle.Observer
import com.module.lemlin.owner.OwnerViewModeFragment
import com.top.mall.R
import com.top.mall.jetpack.vm.AccessViewModel
import kotlinx.android.synthetic.main.fragment_access_register.*

class AccessRegisterFragment : OwnerViewModeFragment<AccessViewModel>() {

    companion object {
        fun newInstance(): AccessRegisterFragment {
            return AccessRegisterFragment()
        }
    }

    override val layoutResId: Int
        get() = R.layout.fragment_access_register

    override fun viewModel(): AccessViewModel {
        return createViewModel()
    }

    override fun initData() {
        viewModel.observableRegister(
            edit_register_phone,
            edit_register_pwd,
            edit_register_pwd_sure,
            edit_register_captcha
        )
    }

    override fun initViewMode() {
        viewModel.isEnabledRegisterLiveData.observe(viewLifecycleOwner, Observer { isEnabled ->
            isEnabled?.let {
                text_register_confirm.isEnabled = it
            }
        })
    }

}